package com.dayuanit.dy15.ebook.bookshop.mapper;

import com.dayuanit.dy15.ebook.bookshop.entity.Commodity;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface CommodityMapper {
    int deleteByPrimaryKey(Long id);

    int insert(Commodity record);

    int insertSelective(Commodity record);

    Commodity selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(Commodity record);

    int updateByPrimaryKeyWithBLOBs(Commodity record);

    int updateByPrimaryKey(Commodity record);

    List<Commodity> listByNavId(@Param("firstNavId") Long firstNavId,
                                @Param("secondNavId") Long secondNavId,
                                @Param("thirdNavId") Long thirdNavId);

    List<Commodity> listByIds(@Param("commodityIds") List<Long> commodityIds);

    int updateStock(@Param("commodityId") Long commodityId,
                    @Param("oldStock") Integer oldStock,
                    @Param("newStock") Integer newStock);

    int plusStock(@Param("commodityId") Long commodityId, @Param("plusNum") Integer plusNum);

    List<Commodity> listTop20();

    List<Commodity> listByIdsNoSort(@Param("commodityIds") List<String> commodityIds);
}